﻿var index = 1;

var WKClick = {
    getAppSetValue: function (keyName) {
        var resultInfo = '';
        var jsonData = {
            path: "/Base/GetAppSetValue",
            param: { keyName: keyName }
        };
        var resultData = WK.click.ajaxRequest(jsonData);
        if (resultData.result && typeof (resultData.obj) == "object") {
            resultInfo = resultData.obj.msg;
        }
        return resultInfo;
    },
    checkPermissions: function (menuId) {
        var resultInfo = '';
        var jsonData = {
            path: "/Base/CheckPermissions",
            param: { menuId: menuId }
        };
        var resultData = WK.click.ajaxRequest(jsonData);
        if (resultData.result) {
            resultInfo = resultData.obj;
        }
        return resultInfo;
    },
    //获取加密解密字符串
    getEnDeCode: function (type, content) {
        var resultInfo = '';
        var jsonData = {
            path: "/Base/GetEnDeCode",
            param: { type: type, content: content }
        };
        var resultData = WK.click.ajaxRequest(jsonData);
        if (resultData.result && typeof (resultData.obj) == "object") {
            resultInfo = resultData.obj.obj;
        }
        return resultInfo;
    },
    //获取Url Json参数值
    getParamVal: function (param, key) {
        var resultInfo = WKClick.getEnDeCode(2, param);
        return resultInfo[key] == undefined ? '' : resultInfo[key];
    }
};

var WK = {
    grid: {
        loadMsg: '数据加载中，请稍后...',
        striped: true,//奇偶数背景颜色
        fit: true,//自适应layout宽高
        fitColumns: true,//列自适应宽度
        rownumbers: true,//是否显示行号
        singleSelect: false,//是否单选
        pagination: true,//是否显示分页控件
        autoRowHeight: false,//定义设置行的高度，根据该行的内容。设置为false可以提高负载性能
        remoteSort: true,//从服务器对数据进行排序
        multiSort: false,//是否允许多列排序
        pagePosition: 'bottom',//分页工具栏显示的位置top、bottom、both
        pageNumber: 1,//初始页
        pageSize: 50,//初始页数据条数
        pageList: [10, 20, 50, 100, 200],
        beforePageText: '第',
        afterPageText: '页 <a href="javascript:WK.grid.jumpIndex();">跳转</a>，共{pages}页',
        displayMsg: '当前显示{from}-{to}条记录，共{total}条记录',
        jumpIndex: function () {//跳转到指定页数
            var thisEvent = jQuery.Event('keydown');
            thisEvent.keyCode = 13;
            $('input.pagination-num').trigger(thisEvent);
        },
        gridData: {
            col: [], doId: '', doIds: ''
        },
        getCheckedId: function (isChecked, jsonObj, gridId, keyId) {
            //所有数据行ID的集合
            var gridIdObj = typeof (gridId) != 'string' || gridId.length == 0 ? 'tb-page-list' : gridId;
            var checkedCol = $('#' + gridIdObj).datagrid('getChecked');
            var checkedId = [];
            for (var i = 0; i < checkedCol.length; i++) {
                checkedId[i] = checkedCol[i][keyId];
            }
            WK.grid.gridData.doIds = checkedId.join(',');
            //最后选择的数据行ID
            if (isChecked) {
                WK.grid.gridData.doId = jsonObj[keyId] == undefined ? '' : jsonObj[keyId];
            } else {
                WK.grid.gridData.doId = '';
            }
        },
        getPagerOptions: function (gridIdObj, type) {
            var pagerOptions = $('#' + gridIdObj).datagrid('getPager').data("pagination").options;
            if (type == 1) {
                return pagerOptions.pageNumber;
            } else if (type == 2) {
                return pagerOptions.pageSize;
            }
        },
        initGridData: function (gridPageIndex, gridPageSize, gridObjId, gridKeyId, gridPath, isShowPic, callbakFuc) {
            var nowPageSize = gridPageSize.length == 0 ? WK.grid.pageSize : gridPageSize;
            $('#' + gridObjId).datagrid({
                loadMsg: WK.grid.loadMsg, striped: WK.grid.striped, fit: WK.grid.fit, fitColumns: WK.grid.fitColumns, rownumbers: WK.grid.rownumbers, singleSelect: WK.grid.singleSelect, pagination: WK.grid.pagination, autoRowHeight: WK.grid.autoRowHeight, pagePosition: WK.grid.pagePosition,
                pageNumber: gridPageIndex.length == 0 ? WK.grid.pageNumber : gridPageIndex,
                pageSize: nowPageSize,
                url: gridPath, columns: [WK.grid.gridData.col],
                onCheck: function (rowIndex, rowData) { WK.grid.getCheckedId(true, rowData, gridObjId, gridKeyId); },
                onUncheck: function (rowIndex, rowData) { WK.grid.getCheckedId(false, rowData, gridObjId, gridKeyId); },
                //以下三行代码事件非常重要
                onBeforeLoad: function (param) { WK.grid.gridData.doIds = ''; WK.grid.gridData.doId = ''; },//数据加载之前
                onSelectAll: function (rows) { setTimeout(function () { WK.grid.getCheckedId(true, {}, gridObjId, gridKeyId); }, 1); },//全选
                onUnselectAll: function (rows) { setTimeout(function () { WK.grid.getCheckedId(false, {}, gridObjId, gridKeyId); }, 1); },//全不选
                onLoadSuccess: function (data) {
                    if (isShowPic) { previewImg(); }
                    if (callbakFuc) {
                        callbakFuc();
                    }
                }
            });
            var pagerBar = $('#' + gridObjId).datagrid('getPager');
            $(pagerBar).pagination({
                pageSize: nowPageSize, pageList: WK.grid.pageList, beforePageText: WK.grid.beforePageText, afterPageText: WK.grid.afterPageText, displayMsg: WK.grid.displayMsg
            });
        },
        formatJsonDate:function(jsonDate) {
            jsonDate = jsonDate.replace("/Date(", "").replace(")/", "");
            if (jsonDate.indexOf("+") > 0) {
                jsonDate = jsonDate.substring(0, jsonDate.indexOf("+"));
            } else if (jsonDate.indexOf("-") > 0) {
                jsonDate = jsonDate.substring(0, jsonDate.indexOf("-"));
            }
            var date = new Date(parseInt(jsonDate, 10));
            var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
            var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
            var minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
            var second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
            return date.getFullYear() + "-" + month + "-" + currentDate + " " + hour + ":" + minute + ":" + second;
        },
        formatLongDate: function (date) {
            var longDate = date.toString();
            return longDate.substr(0, 4) + "-" + longDate.substr(4, 2) + "-" + longDate.substr(6, 2) + " " + longDate.substr(8, 2) + ":" + longDate.substr(10, 2) + ":" + longDate.substr(12, 2);
        }
    },
    ke: {
        width: '900px', height: '400px',
        items: [
            'source', '|',
            'undo', 'redo', '|', 'preview',//'print', 'template', 'code',
            'cut', 'copy', 'paste',
            'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
            'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
            'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
            'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
            'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', //'multiimage',//'flash', 'media', 'insertfile',
            'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',//'anchor',
            'link', 'unlink'//, '|', 'about'
        ],
        resizeType: 0,//2、1或0，2：可以拖动改变宽度和高度、1：只能改变高度、0：不能拖动
        fullscreenMode: false,//初始化是否为全屏
        pasteType: 2,//设置粘贴类型，0：禁止粘贴、 1：纯文本粘贴、2：HTML粘贴
        useContextmenu: true,
        cssData: 'body{font-size:12px}',
        imageTabIndex: 1,//图片弹出层的默认显示标签索引
        fillDescAfterUploadImage: false,//true时图片上传成功后切换到图片编辑标签，false时插入图片后关闭弹出框
        fontSizeTable: ['9px', '10px', '12px', '14px', '16px', '18px', '24px', '26px', '28px', '30px', '32px'],
        uploadJson: '/Contents/DataRequest/UploadKindEditor.ashx'
    },
    uploadify: {
        width: 150,
        height: 30,
        swf: '/Contents/jQueryPlugin/FileUpload/uploadify.swf',
        buttonImage: '/Contents/jQueryPlugin/FileUpload/browse-btn.png',
        multi: false,//是否允许多选
        auto: true,//是否允许自动上传
        fileTypeExts: '*.jpg;*.png',
        fileTypeDesc: 'Image Files (.JPG, .PNG)',
        queueID: 'uploadfileQueue',
        queueSizeLimit: 1,//允许同时上传文件数量
        uploadLimit: 1,//允许上传文件总数，指打开一次浏览器
        fileSizeLimit: '200KB',//限制单个文件大小，限制IIS大小请到Web.Config修改
        buttonText: '选择图片',
        removeCompleted: true//上传完成后是否自动消失
    },
    regular: {
        'empty': /^[ \n]+$/,//空
        'phone': /^((13[0-9])|(15[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))[0-9]{8}$/,//手机
        'tel': /^((\+?[0-9]{2,4}\-[0-9]{3,4}\-)|([0-9]{3,4}\-))?([0-9]{7,8})(\-[0-9]+)?$/,//固话
        'zipCode': /^[1-9][0-9]{5}$/,//邮政编码
        'email': /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,//邮箱
        'qq': /[1-9][0-9]{4,}/,//qq
        'date': /^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/,//时间
        'ip': /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/,//ip
        'mac': /^[A-Fa-f0-9][A-Fa-f0-9]:[A-Fa-f0-9][A-Fa-f0-9]:[A-Fa-f0-9][A-Fa-f0-9]:[A-Fa-f0-9][A-Fa-f0-9]:[A-Fa-f0-9][A-Fa-f0-9]:[A-Fa-f0-9][A-Fa-f0-9]$/,//MAC
        'int': /^[-]{0,1}[0-9]{1,}$/,//整数
        'intZ': /^[0-9]*[1-9][0-9]*$/,//正整数
        'intFF': /^[0-9]*$/,//非负整数
        'decimal': /^[-]{0,1}(\d+)[\.]+(\d+)$/,//小数
        'decimalZ': /^(\d+)[\.]+(\d+)$/,//正小数
        'decimalZ2': /^\d+(\.\d{1,2})?$/,//不超过2位小数的正数
        'decimalF': /^[-](\d+)[\.]+(\d+)$/,//负小数
        'numberLetter': /^[0-9a-zA-Z]+$/,//数字或字母
        'numberLetterH': /^[0-9a-zA-Z\_]+$/,//数字、字母或下划线
        'numberLetterFH': /^[0-9a-zA-Z\-\_\*]+$/,//数字、字母、横线、下划线或*
        'numberLetterC': /^[0-9a-zA-Z\u4e00-\u9fa5]+$/,//数字、字母或汉字
        'idCard': /^[1-9]([0-9]{16}|[0-9]{13})[xX0-9]$///身份证
    },
    click: {
        checkInt: function (text) {
            if (!WK.regular.int.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        checkNumberLetterH: function (text) {
            if (!WK.regular.numberLetterH.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        checkEmail: function (text) {
            if (!WK.regular.email.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        checkIntZ: function (text) {
            if (!WK.regular.intZ.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        checkIntFF: function (text) {
            if (!WK.regular.intFF.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        checkDecimalZ2: function (text) {
            if (!WK.regular.decimalZ2.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        checkNumberLetter: function (text) {
            if (!WK.regular.numberLetter.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        checkDate: function (text) {
            if (!WK.regular.date.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        checkPhone: function (text) {
            if (!WK.regular.phone.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        checkTel: function (text) {
            if (!WK.regular.tel.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        checkIP: function (text) {
            if (!WK.regular.ip.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        checkMAC: function (text) {
            if (!WK.regular.mac.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        checkQQ: function (text) {
            if (!WK.regular.qq.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        checkGUID: function (text) {
            if (!WK.regular.GUID.exec(text)) {
                return false;
            } else {
                return true;
            }
        },
        trimStr: function (text) {
            return $.trim(text);
        },
        setObjVal: function (obj, val) {
            $('#' + obj).val(val);
        },
        setObjFocus: function (obj) {
            $('#' + obj).focus();
        },
        setObjHtml: function (obj, val) {
            $('#' + obj).html(val);
        },
        setObjAttr: function (obj, key, val) {
            $('#' + obj).attr(key, val);
        },
        setObjAttrJson: function (obj, json) {
            $('#' + obj).attr(json);
        },
        setObjCss: function (obj, key, val) {
            $('#' + obj).css(key, val);
        },
        setObjCssJson: function (obj, json) {
            $('#' + obj).css(json);
        },
        setObjDisabled: function (bool) {
            $('input[type=text],input[type=password],input[type=radio],input[type=checkbox],input[type=file],select,textarea').attr('disabled', bool);
        },
        clearVal: function () {
            $('input[type=text],input[type=password],textarea').val('');
        },
        clearHtml: function (text) {
            var reg = /<[^>].*?>/g;
            return text.replace(reg, "");
        },
        delObjAttr: function (obj, attr) {
            $('#' + obj).removeAttr(attr);
        },
        getObjVal: function (obj) {
            return WK.click.trimStr($('#' + obj).val());
        },
        getObjHtml: function (obj) {
            return $('#' + obj).html();
        },
        getUrlVal: function (paramName) {
            var reg = new RegExp('(^|&)' + paramName + '=([^&]*)(&|$)', 'i');
            var r = window.location.search.substr(1).match(reg);
            if (r != null) {
                return unescape(r[2]);
            }
            return '';
        },
        getRandomStr: function (strLength, isOnlyNum, isHaveNum, isUpper) {
            var keyCode = '';
            if (isOnlyNum) {
                keyCode = '0123456789';
            } else {
                if (!isHaveNum) {
                    keyCode = 'abcdefghijklmnopqrstuvwxyz';
                } else {
                    keyCode = '0123456789abcdefghijklmnopqrstuvwxyz';
                }
            }
            var len = parseInt(strLength) || Math.ceil(Math.random() * 5);
            var result = '';
            for (var i = 0; i < len; i++) {
                result += keyCode.charAt(Math.ceil(Math.random() * (keyCode.length - 1)));
            }
            return isUpper ? result.toLocaleUpperCase() : result.toLowerCase();
        },
        //检查是否为js方法（事件）和undefined
        checkClickUndefined: function (type, typeName) {
            if (typeName == undefined) {
                return false;
            }
            if (type == 'click') {
                if (typeof (typeName) != 'function') {
                    return false;
                }
            } else {
                //undefined
                if (typeof (typeName) != 'boolean') {
                    return false;
                }
            }
            return true;
        },
        //检查是否为空
        checkStrNull: function (text) {
            if (WK.regular.empty.exec(text) || text == '') {
                return true;
            }
            return false;
        },
        //设置回车事件
        confirmEvent: function (objId) {
            document.onkeydown = function (e) {
                var ev = document.all ? window.event : e;
                if (ev.keyCode == 13) {
                    $('#' + objId).click();
                }
            };
        },
        ajaxRequest: function (jsonData, doClick) {
            var jsonObj = { result: false, obj: "" };
            $.ajax({
                type: 'post', async: false,
                url: jsonData.path,
                data: jsonData.param,
                success: function (infoData) {
                    jsonObj.result = true;
                    jsonObj.obj = infoData;
                    if (WK.click.checkClickUndefined('click', doClick)) {
                        doClick();
                    }
                },
                error: function (msg) {
                    jsonObj.result = false;
                    try {
                        WK.art.tip('error', '<span class="art-span-error">对不起，数据请求失败：<br/>错误状态：' + msg.status + ';<br/>请求地址：' + jsonData.path + '。<span>');
                    } catch (e) {
                        parent.WK.art.tip('error', '<span class="art-span-error">对不起，数据请求失败：<br/>错误状态：' + msg.status + ';<br/>请求地址：' + jsonData.path + '。<span>');
                    }
                }
            });
            return jsonObj;
        },
        fileUploadify: function (fileID, ajaxPath, imgPathID, imgInfoClass) {
            jQuery("#" + fileID + "").uploadify({
                'width': WK.uploadify.width,
                'height': WK.uploadify.height,
                'buttonImage': WK.uploadify.buttonImage,
                'multi': false,
                'auto': true,
                'successTimeout': 1000,
                'swf': WK.uploadify.swf,
                'queueID': WK.uploadify.queueID,
                'uploader': ajaxPath,
                'fileTypeExts': WK.uploadify.fileTypeExts,
                'fileTypeDesc': WK.uploadify.fileTypeDesc,
                'fileSizeLimit': "800kb",
                'queueSizeLimit': 1,
                'progressData': 'speed',
                'overrideEvents': ['onDialogClose'],
                'buttonText': WK.uploadify.buttonText,
                'onSelectError': function (file, errorCode, errorMsg) {
                    switch (errorCode) {
                        case -100:
                            parent.WK.art.tip("error", "上传的文件数量已经超出系统限制的" + jQuery("#" + fileID + "").uploadify('settings', 'queueSizeLimit') + "个文件！", "");
                            break;
                        case -110:
                            parent.WK.art.tip("error", "文件 [" + file.name + "] 大小超出系统限制的" + jQuery("#" + fileID + "").uploadify('settings', 'fileSizeLimit') + "大小！", "");
                            break;
                        case -120:
                            parent.WK.art.tip("error", "文件 [" + file.name + "] 大小异常！", "");
                            break;
                        case -130:
                            parent.WK.art.tip("error", "文件 [" + file.name + "] 类型不正确！", "");
                            break;
                    }
                },
                'onClearQueue': function (queueItemCount) {
                    //alert("取消上传");
                    return;
                },
                'onQueueComplete': function (queueData) {
                    //alert("文件上传成功！");
                    return;
                },
                'onUploadSuccess': function (file, data, response) {
                    var myData = eval('(' + data + ')');
                    if (myData.state) {
                        //自定义提醒控件
                        if (imgPathID != undefined && imgInfoClass != undefined) {
                            $("#" + imgPathID).val(myData.info);
                            $("." + imgInfoClass).html("<span style='color:green;'>上传成功</span>");
                        } else {
                            $("#hidUploadify").val(myData.info);
                            $(".fileUploadify-info").html("<span style='color:green;'>上传成功</span>");
                        }
                        $('#imgShow').attr({
                            'src': myData.info, 'imgPath': myData.info
                        });
                    } else {
                        try {
                            parent.WK.art.tip("error", myData.info);
                        } catch (e) {
                            alert(myData.info);
                        }
                    }
                }
            });
        },
        fileUploadifySingle: function (divID, fileID, queueID, ajaxPath) {
            $("#" + divID + " .fileUploadify ." + fileID).uploadify({
                'width': WK.uploadify.width,
                'height': WK.uploadify.height,
                'buttonImage': WK.uploadify.buttonImage,
                'multi': false,
                'auto': true,
                'successTimeout': 1000,
                'swf': WK.uploadify.swf,
                'queueID': queueID,
                'uploader': ajaxPath,
                'fileTypeExts': WK.uploadify.fileTypeExts,
                'fileTypeDesc': WK.uploadify.fileTypeDesc,
                'fileSizeLimit': "800kb",
                'queueSizeLimit': 1,
                'progressData': 'speed',
                'overrideEvents': ['onDialogClose'],
                'buttonText': WK.uploadify.buttonText,
                'onSelectError': function (file, errorCode, errorMsg) {
                    switch (errorCode) {
                        case -100:
                            parent.WK.art.tip("error", "上传的文件数量已经超出系统限制的" + $("#" + divID + " .fileUploadify ." + fileID).uploadify('settings', 'queueSizeLimit') + "个文件！", "");
                            break;
                        case -110:
                            parent.WK.art.tip("error", "文件 [" + file.name + "] 大小超出系统限制的" + jQuery("#" + divID + " .fileUploadify ." + fileID).uploadify('settings', 'fileSizeLimit') + "大小！", "");
                            break;
                        case -120:
                            parent.WK.art.tip("error", "文件 [" + file.name + "] 大小异常！", "");
                            break;
                        case -130:
                            parent.WK.art.tip("error", "文件 [" + file.name + "] 类型不正确！", "");
                            break;
                    }
                },
                'onUploadSuccess': function (file, data, response) {
                    var myData = eval('(' + data + ')');
                    if (myData.state) {
                        //自定义提醒控件
                        $("#" + divID + " .hidUploadify").val(myData.info);
                        $("#" + divID +" .fileUploadify-info").html("<span style='color:green;'>上传成功</span>");
                        $('#' + divID + " .imgShow").attr({
                            'src': myData.info, 'imgPath': myData.info
                        });
                    } else {
                        try {
                            parent.WK.art.tip("error", myData.info);
                        } catch (e) {
                            alert(myData.info);
                        }
                    }
                }
            });
        },
        fileUploadifyMult: function (fileID, ajaxPath, orderNum) {
            jQuery("#" + fileID + "").uploadify({
                'width': WK.uploadify.width,
                'height': WK.uploadify.height,
                'buttonImage': WK.uploadify.buttonImage,
                'multi': false,
                'auto': true,
                'successTimeout': 1000,
                'swf': WK.uploadify.swf,
                'queueID': WK.uploadify.queueID,
                'uploader': ajaxPath,
                'fileTypeExts': WK.uploadify.fileTypeExts,
                'fileTypeDesc': WK.uploadify.fileTypeDesc,
                'fileSizeLimit': "800kb",
                'queueSizeLimit': 1,
                'progressData': 'speed',
                'overrideEvents': ['onDialogClose'],
                'buttonText': WK.uploadify.buttonText,
                'onSelectError': function (file, errorCode, errorMsg) {
                    switch (errorCode) {
                        case -100:
                            parent.WK.art.tip("error", "上传的文件数量已经超出系统限制的" + jQuery("#" + fileID).uploadify('settings', 'queueSizeLimit') + "个文件！", "");
                            break;
                        case -110:
                            parent.WK.art.tip("error", "文件 [" + file.name + "] 大小超出系统限制的" + jQuery("#" + fileID).uploadify('settings', 'fileSizeLimit') + "大小！", "");
                            break;
                        case -120:
                            parent.WK.art.tip("error", "文件 [" + file.name + "] 大小异常！", "");
                            break;
                        case -130:
                            parent.WK.art.tip("error", "文件 [" + file.name + "] 类型不正确！", "");
                            break;
                    }
                },
                'onClearQueue': function (queueItemCount) {
                    //alert("取消上传");
                    return;
                },
                'onQueueComplete': function (queueData) {
                    //alert("文件上传成功！");
                    return;
                },
                'onUploadSuccess': function (file, data, response) {
                    //替换物理路径为/
                    var myData = eval('(' + data + ')');
                    if (myData.state) {
                        //自定义提醒控件
                        $("#hidUploadify" + orderNum).val(myData.info);
                        $("#fileUploadify-info" + orderNum).html("<span style='color:green;'>上传成功</span>");
                        //显示图片
                        $("#imgShow" + orderNum).attr({
                            'src': myData.info, 'imgPath': myData.info
                        });
                    } else {
                        try {
                            parent.WK.art.tip("error", myData.info);
                        } catch (e) {
                            alert(myData.info);
                        }
                    }
                }
            });
        },
        photoUploadify: function (fileID, ajaxPath, queueSizeLimit, imgFileUploadPath, imgFileSitePath, imgPathID, imgInfoClass) {
            jQuery("#" + fileID).uploadify({
                'width': WK.uploadify.width,
                'height': WK.uploadify.height,
                'buttonImage': WK.uploadify.buttonImage,
                'multi': true,
                'auto': true,
                'successTimeout': 1000,
                'swf': WK.uploadify.swf,
                'queueID': WK.uploadify.queueID,
                'uploader': ajaxPath,
                'fileTypeExts': WK.uploadify.fileTypeExts,
                'fileTypeDesc': WK.uploadify.fileTypeDesc,
                'fileSizeLimit': '800kb',
                'queueSizeLimit': queueSizeLimit,
                'progressData': 'speed',
                'overrideEvents': ['onDialogClose'],
                'queueID': 'uploadfileQueueMulti',
                'buttonText': WK.uploadify.buttonText,
                'onSelectError': function (file, errorCode, errorMsg) {
                    switch (errorCode) {
                        case -100:
                            parent.WK.art.tip("error", "上传的文件数量已经超出系统限制的" + jQuery("#" + fileID + "").uploadify('settings', 'queueSizeLimit') + "个文件！", "");
                            break;
                        case -110:
                            parent.WK.art.tip("error", "文件 [" + file.name + "] 大小超出系统限制的" + jQuery("#" + fileID + "").uploadify('settings', 'fileSizeLimit') + "大小！", "");
                            break;
                        case -120:
                            parent.WK.art.tip("error", "文件 [" + file.name + "] 大小异常！", "");
                            break;
                        case -130:
                            parent.WK.art.tip("error", "文件 [" + file.name + "] 类型不正确！", "");
                            break;
                    }
                },
                'onClearQueue': function (queueItemCount) {
                    // alert("取消上传");
                    return;
                },
                'onQueueComplete': function (queueData) {
                    // alert("文件上传成功！");
                    return;
                },
                'onUploadSuccess': function (file, data, response) {
                    data = data.replace(/\\/g, '/').replace(imgFileUploadPath, imgFileSitePath);
                    //var myData = JSON.parse(data);
                    var myData = eval('(' + data + ')');
                    if (myData.state == true) {
                        //替换物理路径为/ 
                        data = myData.info.replace(imgFileUploadPath.replace(/\\/g, '/'), imgFileSitePath);
                        var filename = data.substring(data.lastIndexOf("/") + 1);
                        //显示图片
                        var tempPhotoPath = "<div id=divPhoto" + index + " style=\"float:left;text-align:left;vertical-align:top;\">";
                        tempPhotoPath += "<img id='myPhotos' src='" + data + "' style='width:100px;height:75px;' alt='缩略图' imgpath='" + data + "' /> ";
                        tempPhotoPath += " <div style=\"float:left;text-align:left;vertical-align:top;\">";
                        tempPhotoPath += " <a href=\"javascript:;\" onclick=\"DeletePhoto('" + data.replace(imgFileSitePath, "/") + "', 'divPhoto" + index + "', " + myData.imageID + ")\"> 删除</a>";
                        tempPhotoPath += " </div></div> ";
                        document.getElementById("divPhotoList").innerHTML += tempPhotoPath;
                        $("#hidUploadifyMulti").val($("#hidUploadifyMulti").val() + data.replace(imgFileSitePath, "/") + "|");
                        index += 1;
                        previewImg();
                    } else {
                        parent.WK.art.tip("error", myData.info);
                    }
                }
            });
        }
    },
    art: {
        title: '提示信息',
        titlePrompt: '输入信息',
        tip: function (tipIcon, tipContent, enterClick, enterClose) {
            art.dialog({
                id: 'artTip001', lock: true, title: WK.art.title,
                content: '<div class="art-content art-' + tipIcon + '">' + tipContent + '</div>',
                button: [
                    {
                        id: 'artBtn001', value: '确  定',
                        callback: function () {
                            if (WK.click.checkClickUndefined('click', enterClick)) {
                                enterClick();
                            }
                            return WK.click.checkClickUndefined('undefined', enterClose) ? enterClose : true;
                        }
                    }
                ]
            });
        },
        loading: function (loadingContent, loadingTime, loadedClick) {
            art.dialog({
                id: 'artLoading001', lock: true, title: WK.art.title, time: loadingTime,
                content: '<div class="art-content art-loading">' + loadingContent + '</div>',
                beforeunload: function () {
                    if (WK.click.checkClickUndefined('click', loadedClick)) {
                        loadedClick();
                    }
                }
            });
        },
        confirm: function (tipContent, enterClick, enterClose, cancelClick, cancelClose) {
            art.dialog({
                id: 'artConfirm001', lock: true, title: WK.art.title,
                content: '<div class="art-content art-confirm">' + tipContent + '</div>',
                button: [
                    {
                        id: 'artConfirm002', value: '确  定',
                        callback: function () {
                            if (WK.click.checkClickUndefined('click', enterClick)) {
                                enterClick();
                            }
                            return WK.click.checkClickUndefined('undefined', enterClose) ? enterClose : true;
                        }
                    }, {
                        id: 'artConfirm003', value: '取  消',
                        callback: function () {
                            if (WK.click.checkClickUndefined('click', cancelClick)) {
                                cancelClick();
                            }
                            return WK.click.checkClickUndefined('undefined', cancelClose) ? cancelClose : true;
                        }
                    }
                ]
            });
        },
        confirmDel: function (enterClick, enterClose, cancelClick, cancelClose) {
            art.dialog({
                id: 'artConfirmDel001', lock: true, title: WK.art.title,
                content: '<div class="art-content art-confirm">确定要删除选择的数据？</div>',
                button: [
                    {
                        id: 'artConfirmDel002', value: '确  定',
                        callback: function () {
                            if (WK.click.checkClickUndefined('click', enterClick)) {
                                WK.art.loading('数据删除中，请稍后...', 1200, enterClick);
                            }
                            return WK.click.checkClickUndefined('undefined', enterClose) ? enterClose : true;
                        }
                    }, {
                        id: 'artConfirmDel003', value: '取  消',
                        callback: function () {
                            if (WK.click.checkClickUndefined('click', cancelClick)) {
                                cancelClick();
                            }
                            return WK.click.checkClickUndefined('undefined', cancelClose) ? cancelClose : true;
                        }
                    }
                ]
            });
        },
        prompt: function (tipContent, enterClick, defaultValue) {
            defaultValue = defaultValue || '';
            var input;
            return art.dialog({
                id: 'artPrompt001', lock: true, title: WK.art.titlePrompt,
                content: [
                    '<div class="art-prompt">', tipContent, '</div>',
                    '<div>', '<input type="text" class="art-prompt-text" value="', defaultValue, '" />', '</div>'
                ].join(''),
                initialize: function () {
                    input = this.dom.content.find('.art-prompt-text')[0];
                    input.select();
                    input.focus();
                },
                button: [
                    { id: 'artPrompt002', value: '确  定', callback: function () { return enterClick && enterClick.call(this, input.value); } },
                    { id: 'artPrompt003', value: '取  消', callback: function () { return true; } }
                ]
            });
        }
    }
};



$(function () {
    //Ajax异步请求全局加载效果
    $(document).ajaxStart(function () {
        $(document.body).append("<div class='t-c AjaxModal'><div class='loadGif'></div></div>");
        ajaxModal();
        function ajaxModal() {
            var windowHeight = $(window).height();
            var AjaxModal = $('.AjaxModal');
            AjaxModal.bind("touchmove", function (event) {
                event.preventDefault();
            });
            AjaxModal.css({ height: (windowHeight + 200) });
            var loadGif = $('.loadGif');
            var loadDivMar = (windowHeight - 40) / 2;
            loadGif.css({ marginTop: loadDivMar });
        }
        window.onresize = function () {
            ajaxModal();
        };
    }).ajaxComplete(closeLodding).ajaxError(closeLodding);

    //搜索框回车事件
    $(".from-condition .search").keypress(function(e) {
        if (e.keyCode == 13) {
            getList();
        }
    });
});
function closeLodding() {
    $('.AjaxModal').remove();
}